<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sd" uri="/struts-dojo-tags" %>

<script type="text/javascript" src="<s:url value="/js/ethicsCommittee.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/commonAddress.js"/>"></script>

<sd:head parseContent="true"/>

<s:form id="formEdit" cssClass="tableEdit">
    <s:hidden name="id" value="%{comiteEtica.id}"/>
    <s:hidden name="comiteEtica.id" value="%{comiteEtica.id}"/>
    <s:hidden name="address.id" value="%{comiteEtica.address.id}"/>

    <s:textfield label="Name" name="nombre" value="%{comiteEtica.nombre}"/>
    <tr>
        <td class="tdLabel">
            <label class="label">Spanish Safety?:</label>
        </td>
        <td>
            <s:checkbox label="Spanish Safety?" name="requiereSafetyCastellano" value="%{comiteEtica.requiereSafetyCastellano}" theme="simple" />
        </td>
    </tr>

    <s:textfield label="Has List Of Members" name="hasListOfMembers" value="%{comiteEtica.hasListOfMembers}"/>

    <sd:datetimepicker
                label="List Of Members Date"
                name="listOfMembersDate" value="%{comiteEtica.listOfMembersDate}"
                displayFormat="dd/MM/yyyy"
           />

    <s:textfield label="Members Participating" name="membersParticipating" value="%{comiteEtica.membersParticipating}"/>
    <s:textfield label="Members Not Participating" name="membersNotParticipating" value="%{comiteEtica.membersNotParticipating}"/>
    <s:textfield label="GCP Compliance" name="gcpcompliance" value="%{comiteEtica.gcpcompliance}"/>
    <sd:datetimepicker
            label="Final Report" name="finalReport"
            value="%{comiteEtica.finalReport}" displayFormat="dd/MM/yyyy"
            />
    <sd:datetimepicker
            label="Sent To MOH" name="sentToMoh"
            value="%{comiteEtica.sentToMoh}" displayFormat="dd/MM/yyyy"
            />
    <sd:datetimepicker
            label="Inspection Date (only Zieher)" name="inspectionZieherDate"
            value="%{comiteEtica.inspectionZieherDate}" displayFormat="dd/MM/yyyy"
    />
    <sd:datetimepicker
            label="Inspection Results (only Zieher)" name="inspectionZieherResults"
            value="%{comiteEtica.inspectionZieherResults}" displayFormat="dd/MM/yyyy"
    />
    <s:textfield label="SIV Notification (only Zieher)" name="sivnotificationZieher" value="%{comiteEtica.sivnotificationZieher}"/>
    <sd:datetimepicker
            label="Enrollment Authorization (only Zieher)" name="enrollmentAuthorizationZieher"
            value="%{comiteEtica.enrollmentAuthorizationZieher}"  displayFormat="dd/MM/yyyy"
    />
    <s:textfield label="Notification of First Patient (only Zieher)" name="notification1stPatientZieher" value="%{comiteEtica.notification1stPatientZieher}"/>
    <s:textfield label="Local" name="local" value="%{comiteEtica.local}"/>
    <s:textfield label="Sign All Pages" name="signAllPages" value="%{comiteEtica.signAllPages}"/>

    <s:textfield label="Address" name="address.address" value="%{comiteEtica.address.address}"/>

    <s:hidden label="City" name="address.city" id="addressCity" value="%{comiteEtica.address.city}"/>
    <s:hidden label="Province" name="address.province" id="addressProvince" value="%{comiteEtica.address.province}"/>
    <s:hidden label="Country" name="address.country" id="addressCountry" value="%{comiteEtica.address.country}"/>

    <s:if test="%{comiteEtica.id != null}">
        <s:include value="../address/addressedit.jsp"/>
    </s:if>
    <s:else>
        <s:include value="../address/addressview.jsp"/>
    </s:else>


    <TABLE id="table_content" width="350px" >
        <thead>
        <TR>
            <th>Name</th>
            <th>Surname</th>
            <th>Role</th>
            <th>Degree</th>
            <th>email</th>
            <th>Fax</th>
            <th>Phone</th>
        </TR>
        </thead>
        <tbody>
        <s:if test="%{comiteEtica.id == null || comiteEtica.contactPersons.isEmpty()}">
            <TR>
                <TH><s:textfield name="comiteEtica.contactPersons[0].name" value="%{comiteEtica.contactPersons[0].name}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteEtica.contactPersons[0].surname" value="%{comiteEtica.contactPersons[0].surname}" theme="simple" cssClass="required"/></TH>
                <TH>
                    <s:select label="Role" name="comiteEtica.contactPersons[0].role.id" id="role"
                              headerKey="" headerValue="Choose a Role"
                              list="roles"
                              listKey="id"
                              listValue="descripcion"
                              value="%{comiteEtica.contactPersons[0].role.id}"
                              cssClass="required"
                              theme="simple">
                    </s:select>
                </TH>
                <TH><s:textfield name="comiteEtica.contactPersons[0].degree" value="%{comiteEtica.contactPersons[0].degree}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteEtica.contactPersons[0].email" value="%{comiteEtica.contactPersons[0].email}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteEtica.contactPersons[0].fax" value="%{comiteEtica.contactPersons[0].fax}" theme="simple" cssClass="required"/></TH>
                <TH><s:textfield name="comiteEtica.contactPersons[0].phone" value="%{comiteEtica.contactPersons[0].phone}" theme="simple" cssClass="required"/></TH>
                <TH><a onclick="deleteRow('table_content', this)"><img src="<s:url value="/images/delete2.png"/>" alt="Delete"></a></TH>
            </TR>
        </s:if>
        <s:else>
            <s:iterator value="%{comiteEtica.contactPersons}"  status="stat">
                <TR>
                    <TH><s:textfield name="comiteEtica.contactPersons[%{#stat.index}].name" value="%{comiteEtica.contactPersons[#stat.index].name}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteEtica.contactPersons[%{#stat.index}].surname" value="%{comiteEtica.contactPersons[#stat.index].surname}" theme="simple" cssClass="required"/></TH>
                    <TH>
                        <s:select label="Role" name="comiteEtica.contactPersons[%{#stat.index}].role.id" id="role"
                                  headerKey="" headerValue="Choose a Role"
                                  list="roles"
                                  listKey="id"
                                  listValue="descripcion"
                                  value="%{comiteEtica.contactPersons[#stat.index].role.id}"
                                  cssClass="required"
                                  theme="simple">
                        </s:select>
                    </TH>
                    <TH><s:textfield name="comiteEtica.contactPersons[%{#stat.index}].degree" value="%{comiteEtica.contactPersons[#stat.index].degree}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteEtica.contactPersons[%{#stat.index}].email" value="%{comiteEtica.contactPersons[#stat.index].email}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteEtica.contactPersons[%{#stat.index}].fax" value="%{comiteEtica.contactPersons[#stat.index].fax}" theme="simple" cssClass="required"/></TH>
                    <TH><s:textfield name="comiteEtica.contactPersons[%{#stat.index}].phone" value="%{comiteEtica.contactPersons[#stat.index].phone}" theme="simple" cssClass="required"/></TH>
                    <TH><a onclick="deleteRow('table_content', this)"><img src="<s:url value="/images/delete2.png"/>" alt="Delete"></a></TH>
                </TR>
            </s:iterator>
        </s:else>
        </tbody>
    </TABLE>



    <TH><a onclick="addRowCommitee('table_content')"><img src="<s:url value="/images/add2.png"/>" alt="Add Row"></a></TH>

    <br><br>
    <s:submit value="Save" id="save" action="save" onclick="beforeSave();beforeSaveEthicsCommittee();validate()" theme="simple"/>

</s:form>


<script type="text/javascript">
    $("#otherCity").parent().parent().hide();
</script>

<script type="text/javascript">
    $('#ethics').css({"color":"#EE5102","fontWeight":"bold"});
</script>

